//package com.mini.spring.beanfactory.support;
//
//import com.mini.spring.beanfactory.factory.BeanDefinition;
//import com.mini.spring.BeansException;
//
//import java.lang.reflect.Constructor;
//
///**
// * @author: 屠一乐
// * @date: 2023/8/20 17:11
// * @description:
// */
//public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFactory {
//
//    private InstantiationStrategy instantiationStrategy = new CglibSubclassingInstantiationStrategy();
//
//    @Override
//    protected Object createBean(String beanName, BeanDefinition beanDefinition, Object[] args) throws BeansException {
//        Object bean = null;
//        try {
//            bean = createBeanInstance(beanDefinition, beanName, args);
//        } catch (Exception e) {
//            throw new BeansException("Instantiation of bean failed", (ReflectiveOperationException) e);
//        }
//
//        addSingleton(beanName, bean);
//        return bean;
//    }
//
//    protected Object createBeanInstance(BeanDefinition beanDefinition, String beanName, Object[] args) throws BeansException {
//        Constructor constructorToUse = null;
//        Class<?> beanClass = beanDefinition.getBeanClass();
//        Constructor<?>[] declaredConstructors = beanClass.getDeclaredConstructors();
//        for (Constructor ctor : declaredConstructors) {
//            if (null != args && ctor.getParameterTypes().length == args.length) {
//                constructorToUse = ctor;
//                break;
//            }
//        }
//        return getInstantiationStrategy().instantiate(beanDefinition, beanName, constructorToUse, args);
//    }
//
//    private InstantiationStrategy getInstantiationStrategy() {
//        return null;
//    }
//
//}